home *** CD-ROM | disk | FTP | other *** search
/ Apple Reference & Present…nuary (Partner) - Disc 2 / The Apple Reference and Presentations Library (Disc 2)(January 1994).iso / Synergy Software / Japanese / KaleidaGraph˛-PPC / Examples folder / Macro Library / Macro Library
Text File  |  1993-04-14  |  3KB  |  135 lines

  1. ; Copyright 1989-1993 by Abelbeck Software
  2. ;
  3. ; Macro Library
  4. ; Version 1.0
  5. ; March 30, 1990
  6. ;
  7. ; Definitions for the "Formula" and "General Curve Fit"
  8. ;
  9. ;__Variable Definitions
  10. x = m0;
  11. a = m1;
  12. b = m2;
  13. c = m3;
  14. d = m4;
  15. ;
  16. ;__Constant Definitions
  17. e = exp(1);
  18. ;
  19. ;__Aliases
  20. OR = ||;
  21. AND = &&;
  22. MOD = %;
  23. if(bool) = bool ?;
  24. else = :;
  25. ;
  26. ;__Mathematical Function Definitions
  27. ; Hyperbolic sine
  28. sinh(x) = ((exp(x) - exp(-x)) / 2);
  29. ;
  30. ; Hyperbolic cosine
  31. cosh(x) = ((exp(x) + exp(-x)) / 2);
  32. ;
  33. ; Hyperbolic tangent
  34. tanh(x) = ((exp(x) - exp(-x)) / (exp(x) + exp(-x)));
  35. ;
  36. ; Log base 2
  37. log2(x) = (log(x) / log(2));
  38. ;
  39. ; Log base n
  40. logn(x, n) = (log(x) / log(n));
  41. ;
  42. ;__Misc. Definitions
  43. ; Random # with upper and lower bounds
  44. number(lower, upper) = ((ran() * (upper - lower)) + lower);
  45. ;
  46. ; Arithmetic series
  47. series(a, b) = (c0 = a + b * index());
  48. ;
  49. ; Sinc
  50. sinc(x) = ((x) == 0.0) ? 1 : (sin(x)/(x));
  51. ;
  52. ; Minimum of two numbers
  53. min(a, b) = (a < b ? a : b);
  54. ;
  55. ; Maximum of two numbers
  56. max(a, b) = (a > b ? a : b);
  57. ;
  58. ; Limit x between a and b
  59. limit(a, b, x) = (x < a ? a : (x > b ? b : x));
  60. ;
  61. ; Column Sum
  62. sum(x) = m0 = 0\;m0 = m0 + x\;m0;
  63. ;
  64. ; Running Sum
  65. runsum(x, sum) = m0 = 0\;sum = (m0 = m0 + x);
  66. ;
  67. ; Filter (Mask) data outside of min and max
  68. filter(min, max, x) = unmask(1, x)\;mask(x < min || x > max, x);
  69. ;
  70. ; Quadratic Equation +
  71. quadroot1(a, b, c) = ((-b + sqrt(b^2 - 4*a*c)) / (2 * a));
  72. ;
  73. ; Quadratic Equation -
  74. quadroot2(a, b, c) = ((-b - sqrt(b^2 - 4*a*c)) / (2 * a));
  75. ;
  76. ; Name base column "str"
  77. cname(str) = name(str, c0);
  78. ;
  79. ;__Curve Fit Definitions
  80. ; Linear curve fit through the origin
  81. line0fit(a0) = a*x\;
  82. a=a0;
  83. ;
  84. ; Linear curve fit
  85. linefit(a0, b0) = a + b*x\;
  86. a=a0\;b=b0;
  87. ;
  88. ; Exponential base e curve fit
  89. expfit(a0, b0) = a * exp(b*x)\;
  90. a=a0\;b=b0;
  91. ;
  92. ; Exponential base 10 curve fit
  93. exp10fit(a0, b0) = a * 10^(b*x)\;
  94. a=a0\;b=b0;
  95. ;
  96. ; Exponential base n curve fit
  97. expnfit(n, a0, b0) = a * n^(b*x)\;
  98. a=a0\;b=b0;
  99. ;
  100. ; Exponential-Cosine curve fit
  101. expcosfit(a0, b0, c0, d0) = a * exp(-b*x) * cos(c*x + d)\;
  102. a=a0\;b=b0\;c=c0\;d=d0;
  103. ;
  104. ; Exponential-Exponential curve fit
  105. expexpfit(a0, b0, c0, d0) = a * exp(-b*x) + c * exp(-d*x)\;
  106. a=a0\;b=b0\;c=c0\;d=d0;
  107. ;
  108. ; General Exponential curve fit
  109. genexpfit(a0, b0, c0) = a + b * (1 - exp(-c*x))\;
  110. a=a0\;b=b0\;c=c0;
  111. ;
  112. ; Cosine curve fit
  113. cosfit(a0, b0, c0, d0) = a + b * cos(c*x + d)\;
  114. a=a0\;b=b0\;c=c0\;d=d0;
  115. ;
  116. ; Gaussian curve fit
  117. gaussfit(a0, b0, c0, d0) = a + b * exp(-(x - c)^2 / d^2)\;
  118. a=a0\;b=b0\;c=c0\;d=d0;
  119. ;
  120. ; Power curve fit
  121. powerfit(a0, b0) = a * x^b\;
  122. a=a0\;b=b0;
  123. ;
  124. ; Log base 10 curve fit
  125. logfit(a0, b0) = a + b * log(x)\;
  126. a=a0\;b=b0;
  127. ;
  128. ; Log base e curve fit
  129. lnfit(a0, b0) = a + b * ln(x)\;
  130. a=a0\;b=b0;
  131. ;
  132. ; Log base n curve fit
  133. lognfit(n, a0, b0) = a + b * logn(x, n)\;
  134. a=a0\;b=b0;
  135. ;